/*
 * Copyright 2003-2005 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */
package com.argot.meta;

import java.io.IOException;

import com.argot.TypeException;
import com.argot.TypeLibraryWriter;
import com.argot.TypeMap;
import com.argot.TypeOutputStream;
import com.argot.TypeWriter;
import com.argot.common.BigEndianUnsignedByte;

public class MetaBasic
extends MetaBase
implements MetaDefinition
{
	public static String TYPENAME = "meta.basic";
		
	private short _width;
	private short _flags;
	
	public MetaBasic( short width, short flags )
	{
		_width = width;
		_flags = flags;
	}

	public MetaBasic( int width, int flags )
	{
		_width = (short) width;
		_flags = (short) flags;
	}
	
    public String getTypeName()
    {
        return TYPENAME;
    }

    public static class MetaBasicTypeWriter
    implements TypeLibraryWriter,TypeWriter
    {
		public void write(TypeOutputStream out, Object o ) 
		throws TypeException, IOException
		{
			MetaBasic tb = (MetaBasic) o;
			
			out.writeObject( BigEndianUnsignedByte.TYPENAME, new Short( tb._width ));
			out.writeObject( BigEndianUnsignedByte.TYPENAME, new Short( tb._flags ));
		}
		
		public TypeWriter getWriter(TypeMap map) 
		throws TypeException 
		{
			return this;
		}		
    }


}
